package com.gshrms.org.domain;

import java.util.*;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gshrms.common.core.domain.CommonEntity;
import com.gshrms.common.core.domain.TreeEntity;
import com.gshrms.org.domain.dto.OrgRoleStaffJoinDto;
import com.gshrms.system.domain.dto.SysUserJoinDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.gshrms.common.annotation.Excel;

import javax.validation.constraints.NotBlank;

/**
 * 组织对象 org_info
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@Data
public class OrgInfo extends CommonEntity
{
    private static final long serialVersionUID = 1L;

    /** 组织ID */
    @TableId
    private Long orgId;

    /** 父菜单ID */
    private Long parentId;

    @TableField(exist = false)
    private String parentName;

    /** 祖级列表 */
    private String ancestors;

    private String ancestorsJson;

    /** 组织唯一编码 */
    @Excel(name = "组织唯一编码")
    private String orgNo;

    /** 组织名称 */
    @Excel(name = "组织名称")
    @NotBlank(message = "组织名称不能为空")
    private String orgName;

    /** 组织描述 */
    @Excel(name = "组织描述")
    private String orgDesc;


    /** 税号 */
    @Excel(name = "税号")
    private String taxNo;

    /** 组织说明书 */
    private String explainFile;

    /** 虚拟组织（1是、0否） */
    @Excel(name = "虚拟组织", readConverterExp = "1=是,0=否")
    private String virtualFlag;


    /** 父菜单名称 */
    @TableField(exist = false)
    private String parentNo;

    /** 祖级列表名称 */
    @TableField(exist = false)
    private String ancestorsNo;

    @TableField(exist = false)
    private String ancestorsName;

    /** 祖级列表名称 */
    @TableField(exist = false)
    private String ancestorsTaxNo;





    /** 设立日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "设立日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date setupTime;

    @ApiModelProperty("部门负责人")
    private String deptStaffIds;

    @ApiModelProperty("分管领导人")
    private String leaderStaffIds;

    @ApiModelProperty("组织主管")
    private String managerStaffIds;

    @ApiModelProperty("组织管理员")
    private String adminStaffIds;


    /** 组织状态（0正常 1停用） */
    @Excel(name = "组织状态", readConverterExp = "0=正常,1=停用")
    private String status;

    @ApiModelProperty("显示顺序")
    private Integer orderNum;

    /** 创建人 */
    private Long createId;

    @TableField(exist = false)
    private SysUserJoinDto createInfo;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 角色人员组 */
    @TableField(exist = false)
    private List<OrgRoleStaffJoinDto> orgRoleStaffJoin;

    @TableField(exist = false)
    private HashMap<String, OrgRoleStaffJoinDto> orgRoleStaffJoinDict;

    @ApiModelProperty("子部门")
    @TableField(exist = false)
    private List<?> children = new ArrayList<>();

    @TableField(exist = false)
    private Long userId;

    @TableField(exist = false)
    private Long menuId;

    @TableField(exist = false)
    private String userType;


    public HashMap<String, OrgRoleStaffJoinDto> getOrgRoleStaffJoinDict() {
        HashMap<String, OrgRoleStaffJoinDto> orgRoleStaffJoinDict = new HashMap<>();
        if(this.orgRoleStaffJoin == null) return orgRoleStaffJoinDict;

        for(OrgRoleStaffJoinDto obj : this.orgRoleStaffJoin){
            orgRoleStaffJoinDict.put("roleId"+obj.getRoleId(), obj);
        }
        return orgRoleStaffJoinDict;
    }




}
